package thread;

public class SleepDemo {
    public static void main(String[] args) {
        MyThread myThread = new MyThread("线程1");
//        myThread.setPriority(10);
        //getPriority()获取线程的优先级
        System.out.println(myThread.getPriority()); //默认是5,s设置优先级后是10
        System.out.println(Thread.currentThread().getPriority());//当前线程的优先级
        myThread.start();

        try {
            // main 线程等待(阻塞),myThread线程执行完毕后再执行main
            myThread.join(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        for (int i = 0; i < 10; i++) {
            System.out.println("main线程执行了" + i + "次");
        }


    }
}
